﻿Public Class FormPhieuNhap

    Private Sub FormPhieuNhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadNCC()
        LoadHangHoa()
    End Sub

    Private Sub LoadNCC()
        Dim dt As New DataTable
        dt = DoiTacDAO.Select_All()
        cmbNCC.DataSource = dt
        cmbNCC.DisplayMember = "MaDoiTac"
        cmbNCC.ValueMember = "MaDoitac"
    End Sub

    Private Sub LoadHangHoa()
        Dim dt As New DataTable
        dt = LoaiHangDAO.Select_All()
        cmbLoaiHang.DataSource = dt
        cmbLoaiHang.DisplayMember = "MaLoai"
        cmbLoaiHang.ValueMember = "MaLoai"
    End Sub

    Private Sub pcbNCC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pcbNCC.Click
        Dim frmDoiTac As New QuanLyDoiTac
        frmDoiTac.ShowDialog()
    End Sub

    Private Sub pcbHangHoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pcbHangHoa.Click
        Dim frmHH As New frmHangHoa
        frmHH.ShowDialog()
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub cmbNCC_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbNCC.SelectedIndexChanged

        Dim dt As New DataTable
        Dim _doiTac As New DoiTacDTO
        Dim maDT As String = cmbNCC.SelectedValue.ToString()
        dt = DoiTacDAO.Select_By_Ma(maDT)
        If dt.Rows.Count > 0 Then
            _doiTac.TenDoiTac = dt.Rows(0).Item(1).ToString()
            _doiTac.DiaChi = dt.Rows(0).Item(2).ToString()
            _doiTac.MST = dt.Rows(0).Item(3).ToString()
            _doiTac.KiHieuHoaDon = dt.Rows(0).Item(4).ToString()
            _doiTac.DienThoai = dt.Rows(0).Item(5).ToString()
            _doiTac.NguoiLienLac = dt.Rows(0).Item(6).ToString()
            _doiTac.Email = dt.Rows(0).Item(7).ToString()
        End If
        txtTenNCC.Text = _doiTac.TenDoiTac
        txtDiaChi.Text = _doiTac.DiaChi
        txtMST.Text = _doiTac.MST
        lbKHHD.Text = _doiTac.KiHieuHoaDon
        lbDienThoai.Text = _doiTac.DienThoai
        lbNguoiLienHe.Text = _doiTac.NguoiLienLac
        lbEmail.Text = _doiTac.Email
    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub
End Class